//! \file GuiOpenGL.cpp
//! \brief TODO: Document
// -----------------------------------------------------------------------------
//! This program is free software; you can redistribute it and/or
//! modify it under the terms of the GNU General Public License
//! as published by the Free Software Foundation; either version 2
//! of the License, or (at your option) any later version.
//!
//! This program is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//! GNU General Public License for more details.
//!
//! You should have received a copy of the GNU General Public License
//! along with this program; if not, write to the Free Software Foundation,
//! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// -----------------------------------------------------------------------------

#include "GuiOpenGL.h"

// =====[ Local Definitions ]===================================================

// =====[ Local DataTypes ]=====================================================

// =====[ Local Variables ]=====================================================
GuiOpenGL* GuiOpenGL::m_pGuiOpenGL = NULL;         //!< The singleton object instance.

// =====[ Local Functions ]=====================================================

// =====[ Private (Internal) Methods ]==========================================

// =====[ Local Implementation ]================================================


// =============================================================================
// GuiOpenGL::getSingleton
// -----------------------------------------------------------------------------
//! Returns a reference to the instanced singleton object.
//!
//! \retval Singleton
//!   A reference to the instanced singleton object.
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
GuiOpenGL& GuiOpenGL::getSingleton()
{
  // Only allow one instance of class to be generated.
  if (!m_pGuiOpenGL) { m_pGuiOpenGL = new GuiOpenGL; }   // Create our single instance.
  return (*m_pGuiOpenGL);                          // Finally, return our singleton.
}


// =============================================================================
// GuiOpenGL::getSingletonPtr
// -----------------------------------------------------------------------------
//! Returns a pointer to the instanced singleton object.
//!
//! \retval Singleton
//!   A pointer to the instanced singleton object.
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
GuiOpenGL* GuiOpenGL::getSingletonPtr()
{
  // Only allow one instance of class to be generated.
  if (!m_pGuiOpenGL) { m_pGuiOpenGL = new GuiOpenGL; }   // Create our single instance.
  return (m_pGuiOpenGL);                           // Finally, return our singleton.
}


// =============================================================================
// GuiOpenGL::start
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
tERROR GuiOpenGL::start(void)
{
  // Configure OpenGL to host our SDL surface and CEGUI.
  glEnable(GL_CULL_FACE);                       // Enable the culling of polygons based on their winding in window coordinates.
  glDisable(GL_FOG);                            // Disable the blending of a fog color into the post-texturing color.
  glClearColor(0.0f,0.0f,0.0f,1.0f);            // Specify clear values for the color buffers.
  glViewport(0,0, 800,600);                     // Set the OpenGL view port.

  glMatrixMode(GL_PROJECTION);                  // TODO: comment
  glLoadIdentity();                             // TODO: comment
  gluPerspective(45.0, 800.0/600.0, 0.1,100.0); // TODO: comment
  glMatrixMode(GL_MODELVIEW);                   // TODO: comment
  glLoadIdentity();                             // TODO: comment

  // Return success.
  return (ERR_NONE);
}


// =============================================================================
// GuiOpenGL::stop
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
tERROR GuiOpenGL::stop(tERROR Error)
{
  // Return the original error code.
  return (Error);
}


// =============================================================================
// FxName
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
tERROR GuiOpenGL::clear(void)
{
  // Clear the OpenGL color buffer.
  glClear(GL_COLOR_BUFFER_BIT);
}
